<template>
	<div>
		<div class="pic">
			<div class="in">
				<router-link to="/adm/firsttype"><div class="pcd"><返回</div></router-link>
				<div v-model="from.pid=0">
				</div>
				<div>
					<input placeholder="一级id" v-model="from.id" />
				</div>
				<div>
					<input placeholder="一级类型-名称" v-model="from.name" />
				</div>
				<div>
					<input placeholder="显示顺序" v-model="from.prio" />
				</div>
					<div>
						<router-link to="/adm/firsttype">
							<button class="a" @click="add()">添加</button>
						</router-link>
						
					</div>
					
				
			</div>
		</div>
	</div>
</template>

<script>
	export default{
		name:"add1",
		data() {
			return {
				from: {
					pid:'',
					id: '',
					name: '',
					prio: '',
				}
			}
		},
		methods: {
		add(){
			let fd=new FormData();
			// fd.append('id',this.from.id);
			fd.append('pid',this.from.pid);
			fd.append('name',this.from.name);
			fd.append('prio',this.from.prio);
			console.log(fd);
			this.$axios.post("/api/adm/type/add", fd).then((resp) => {
				if(resp.status==200){
					this.from=resp.data.data;
					console.log(resp.data.data);
				}
			}).catch((error)=>{
				console.log(error);
			})
		}
		},
		mounted() {
			console.log(this.$route)
			this.from = this.$route.query;
			console.log(this.from)
		}
	}
</script>

<style>
	.pcd{
		color: #aac8b4;
		font-size: 1.5rem;
	}
</style>
